<?php
declare (strict_types=1);

namespace app\api\controller;

use think\response\Json;
use app\api\model\Help as HelpModel;
use app\api\model\HelpCategory as HelpCategoryModel;


class Help extends Controller
{
    public function index()
    {
        $model = new HelpModel;
        $list = $model->getList($this->request->param())->toArray();
        return $this->renderSuccess([
            'total' => $list['total'],
            'items' => $list['data']
        ]);
    }

    public function detail(int $id=0): Json
    {
        $model = new HelpModel;
        $data = $id?$model->detail($id):null;
        return $this->renderSuccess($data?$data->toArray():[]);
    }
    public function category()
    {
        $model = new HelpCategoryModel;
        $list = $model->getAll()->toArray();
        return $this->renderSuccess($list);
    }
}
